package com.example.myapplication.entity

import android.os.Parcel
import android.os.Parcelable

class CloudBean(
    var cloudName: String = "",
    var cloudCheck: Boolean = false,
    var isPublic: Boolean = false, // 是否是公有云
    var ip: String = "",
    var port: String = "",
    var userName: String = ""
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString() ?: "",
        parcel.readByte() != 0.toByte(),
        parcel.readByte() != 0.toByte(),
        parcel.readString() ?: "",
        parcel.readString() ?: "",
        parcel.readString() ?: ""
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(cloudName)
        parcel.writeByte(if (cloudCheck) 1 else 0)
        parcel.writeByte(if (isPublic) 1 else 0)
        parcel.writeString(ip)
        parcel.writeString(port)
        parcel.writeString(userName)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<CloudBean> {
        override fun createFromParcel(parcel: Parcel): CloudBean {
            return CloudBean(parcel)
        }

        override fun newArray(size: Int): Array<CloudBean?> {
            return arrayOfNulls(size)
        }
    }
}